module Initional_Condition
    use CommData
    use operations_mod
    use Qmat_mod
    use Phi_mod
    use readfile_mod
    implicit none
  contains
    
    subroutine init_cond
        real*8 Cp
        call read_file
        call make_adjacency_matrix
        
        allocate(x_new(num_cord))
        allocate(y_new(num_cord))
        allocate(entropy_array(num_vol))
        allocate(Eff(9,num_vol))
        allocate(Plast(9,num_vol))
        allocate(Qmat(3,3))
        allocate(q(21,num_vol))
        allocate(p(12,num_vol))
        allocate(center_mass_x(num_vol))
        allocate(center_mass_y(num_vol))
        allocate(Energy(num_vol))
        allocate(pmid(4, num_vol, 3))
        allocate(Phi_array(num_vol))
        Energy = 1d0; Eff = 0d0; Plast = 0d0;
        x_new = 0d0; y_new = 0d0;
        Eff(1,:) = 1d0;Eff(5,:) = 1d0;Eff(9,:) = 1d0;
        Plast(1,:) = 1d0;Plast(5,:) = 1d0;Plast(9,:) = 1d0;  
        q(4,:) = 1d0;q(8,:) = 1.d0;q(13,:) = 1d0;
        q(12,:) = 1d0;q(17,:) = 1.d0;q(21,:) = 1d0;
        entropy_array = 1d0;
        GAMMA = 4d0; BETA  = 1d0; ro = 1d0;
        Cp = 5d0**2; C1 = 3d0**2; 
        C0 = (3d0*Cp - 4d0*C1)/3d0;
        
        call Phi(eff,Phi_array)
        call entropy(eff,Phi_array)
        
    end subroutine init_cond
end module Initional_Condition